import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class demo1 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //创建一个任务
        Callable<Integer> callable = new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                int sum = 0;
                for(int i = 0; i <= 10; i++)
                {
                    sum += i;
                }
                return sum;
            }
        };

        //需要有一个未来任务来获取该任务， 相当于吃麻辣烫的时候给的小票， 凭借该小票就可以来获取麻辣烫
        FutureTask<Integer> futureTask = new FutureTask<>(callable);
        Thread t = new Thread(futureTask);
        t.start();

        
        System.out.println(futureTask.get());

    }
}
